﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Runtime.InteropServices;
using SlimDX;
using D3D = SlimDX.Direct3D10;

namespace SCS.GFX {

    [StructLayout(LayoutKind.Sequential)]
    public struct PositionColored
    {

        public static int SizeInBytes = Marshal.SizeOf(typeof(PositionColored));
        public static D3D.InputElement[] InputElements = new D3D.InputElement[]{
				new D3D.InputElement("POSITION", 0, SlimDX.DXGI.Format.R32G32B32_Float, 0, 0),
				new D3D.InputElement("COLOR", 0, SlimDX.DXGI.Format.R32G32B32A32_Float, 12, 0)
    };

        private Vector3 FPosition;
        public Vector3 Position
        {
            get { return FPosition; }
            set { FPosition = value; }
        }

        public float X
        {
            get { return FPosition.X; }
            set { FPosition.X = value; }
        }

        public float Y
        {
            get { return FPosition.Y; }
            set { FPosition.Y = value; }
        }

        public float Z
        {
            get { return FPosition.Z; }
            set { FPosition.Z = value; }
        }

        private Vector4 FColor;
        public Vector4 Color
        {
            get { return FColor; }
            set { FColor = value; }
        }

        public PositionColored(Vector3 aPosition, Vector4 aColor)
        {
            FPosition = new Vector3(aPosition.X, aPosition.Y, aPosition.Z);
            FColor = aColor;
            //FColor = new Vector4(0.0f, 0.0f, 0.0f, 0.0f);
        }

        public PositionColored(float aX, float aY, float aZ, Vector4 aColor)
        {
            FPosition = new Vector3(aX, aY, aZ);
            FColor = aColor;
            //FColor = aColor;
            //FColor = new Vector4(0.0f, 0.0f, 0.0f, 0.0f);
        }
/*
        public PositionColored(Vector3 aPosition, System.Drawing.Color aColor)
        {
            FPosition = new Vector3(aPosition.X, aPosition.Y, aPosition.Z);
            FColor = System.Drawing.Color.FromKnownColor(aColor.ToKnownColor());
            //FColor = new Vector4(0.0f, 0.0f, 0.0f, 0.0f);
        }

        public PositionColored(float aX, float aY, float aZ, System.Drawing.Color aColor)
        {
            FPosition = new Vector3(aX, aY, aZ);
            FColor = System.Drawing.Color.Red;
            //      FColor = aColor.ToArgb();
           // FColor = new Vector4(0.0f, 0.0f, 0.0f, 0.0f);

        }
*/
        public override string ToString()
        {
            StringBuilder s = new StringBuilder(base.ToString());
            s.Append(" Position=");
            s.Append(FPosition);
            s.Append(" Color=");
            s.Append(Color);
            return s.ToString();
        }

    }
}
